package edu.gatech.stolen.tea.display.item;

import java.util.ArrayList;

import edu.gatech.stolen.tea.R;
import edu.gatech.stolen.tea.R.id;
import edu.gatech.stolen.tea.R.layout;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;

public class EditItemActivity extends Activity {
	
	private TextView userTextView;
	//private User yourUser;
	private Spinner selectionSpinner;
	private EditText editBox;
	private ArrayList<String> options;
	private Button editButton;
	//private String item;
	
	public static final String TAG = "Edit Item Page";
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
    	
    	Log.v(TAG, "Activity State: onCreate()");
        super.onCreate(savedInstanceState);
        setContentView(R.layout.edititem);
        
        options = new ArrayList<String>();
        options.add("Name");
        options.add("Description");
        options.add("Location");
        options.add("Date Given");
        options.add("Due Date");
        
        ArrayAdapter<String> optionAdapter = new ArrayAdapter<String>(this,
        		android.R.layout.simple_spinner_item, options);
        optionAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        selectionSpinner.setAdapter(optionAdapter);
        
        userTextView = (TextView) findViewById(R.id.tUserTextView_edititem);
        selectionSpinner = (Spinner) findViewById(R.id.sSelectionSpinner_edititem);
        editBox = (EditText) findViewById(R.id.eEditItemEditText_edititem);
        editButton = (Button) findViewById(R.id.bEditButton_edititem);
        
        //userTextView.setText(ItemManager.getCurrentItem().getName());
        
        editButton.setOnClickListener(new OnClickListener() {
        	 
      	  
      	  public void onClick(View v) {
      		  
      		  String choice = String.valueOf(selectionSpinner.getSelectedItem());
      		  String change = editBox.getText().toString();
      		  
      		 // ItemManager.editItem(choice, change);
      		  goToItemDisplayListPage();
      		  
      	  }
       
      	});
    	
    }
    
    protected void goToItemDisplayListPage() {
    	
    	Intent i = new Intent(this, ItemDisplayListActivity.class);
    	startActivity(i);
   	
    } 
}